<?php

namespace App\Http\Resources\Estate\PaymentLogResource;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;

class PaymentLogCollection extends ResourceCollection
{
    protected $dates=['create_time'];
    /**
     * Transform the resource collection into an array.
     *
     * @param Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'data'         => $this->collection->map(function ($item) {
                return [
                    'id'         => $item->id,
                    'orderNo'      => $item->orderNo,
                    'feeType'      => $item->feeType,
                    'username'       =>  $item->user_info->username,
                    'paymentMoney'        => $item->paymentMoney,
                    'pay_type'  => $item->pay_type,
                    'pay_no'  => $item->pay_no,
                    'create_time' => $item->create_time,
                    'paymentTime' => $item->paymentTime,
                ];
            }),
            'total'        => $this->total(), // 数据总数
            'per_page'     => $this->perPage(), // 每页数量
            'current_page' => $this->currentPage(), // 当前页码
        ];
    }
}
